#include <bits/stdc++.h>
using namespace std;

int diff[8][2] = {{0,-1},{0,1},{-1,0},{1,0},
				  {-1,-1},{1,-1},{-1,1},{1,1}};
const int maxn = 110;
int a[maxn][maxn] = {0};
char c[maxn][maxn] = {0};
int main() {
	int n = 0, m = 0;
	cin >> n >> m;
	for (int i=0; i<n; i++) {
		cin >> c[i+1] + 1;
	}

	for(int i=1; i<=n; i++) {
		for (int j=1; j<=m; j++) {
			if (c[i][j] == '*') {
				a[i][j] = -1; 
				for(int k=0; k<8; k++) {
					int ti = i+diff[k][0];
					int tj = j+diff[k][1];
					if (ti>=1 && ti<=n && tj>=1 && tj<=m && c[ti][tj] == '?') {
						a[ti][tj] += 1;
					} 
				}	
			}			 
		}
	}
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=m; j++) {
			if (a[i][j] == -1) {
				cout << '*';
			} else {
				cout << a[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}
